<template>
	<view class="box">
		<view class="list">
			<view class="demo fw-bt" v-for="(item,index) of list" :key="index">
				<view>{{item.mar_name}}</view>
				<view class="btn" @click="openPop(index,item.id)">{{isMakrQrImageSee(item.id)}}</view>
			</view>
		</view>
		<!-- 群弹窗 -->
		<uni-popup ref="popup" type="center" :isMaskClick="false">
			<view class="pop">
				<view class="p1">
					<view class="p1-img f-w">
						<image src="https://jw.xzsw2021.com/static/big/tu@2x.png" mode=""></image>
						<view class="p-top">
							<!-- 店铺名 -->
							<view class="f26">{{chooseitem.mar_name}}</view>
							<!-- 店铺名 -->
							<view class="desc">快快扫码加群吧</view>
						</view>
					</view>
					<view class="p1-c">
						<view class="p-t">截图-保存-打开微信，识别二维码</view>
						<view class="p-ewm">
							<image :src="chooseitem.qr_image" mode=""></image>
						</view>
					</view>
				</view>
				<view class="pclose" @click="close">
					<image src="https://jw.xzsw2021.com/static/index/icon_19@2x.png" mode=""></image>
				</view>
			</view>
		</uni-popup>
	</view>

</template>

<script>
	import Cache from '@/util/cache.js'
	export default {
		data() {
			return {
				list: [], //群列表
				chooseitem: ''
			}
		},
		mounted() {
			this.getlist()
			// this.$refs.popup.open()
		},
		methods: {
			getlist() {
				let data = {
					lat: uni.getStorageSync('market').latitude,
					lng: uni.getStorageSync('market').longitude
				}
				this.$request('market/lst', data, 'GET').then(res => {
					if (res.status == 200) {
						res.data.is_add = false
						this.list = res.data
					}
				})
			},
			// 打开群弹窗
			openPop(index, mar_id) {
				let list = this.list
				list[index].is_add = true
				this.chooseitem = list[index]
				Cache.set(`isMakrQrcodeSee:${mar_id}`, 1111) //设置缓存
				this.list = list
				this.$refs.popup.open()
			},
			//关闭
			close() {
				this.$refs.popup.close()
			},
			/**
			 * 是否查看过粉丝群二维码
			 * @param {Object} mar_id
			 */
			isMakrQrImageSee(mar_id) {
				let see = Cache.get(`isMakrQrcodeSee:${mar_id}`)
				if (see == 1111) {
					return '已查看';
				} else {
					return '加群';
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.box {
		.list {
			padding: 0 30rpx 30rpx;

			.demo {
				border-bottom: 1rpx solid #eee;
				height: 140rpx;

				.btn {
					width: 140rpx;
					height: 72rpx;
					line-height: 72rpx;
					text-align: center;
					color: #fff;
					font-size: 28rpx;
					background: linear-gradient(64deg, #2BCCA5, #22B591);
					box-shadow: 0rpx 4rpx 6rpx 0rpx rgba(20, 187, 146, 0.4);
					border-radius: 10rpx;
				}
			}
		}

		.pop {
			width: 630rpx;
			min-height: 800rpx;

			.p1 {
				height: 800rpx;
				background: #FFFFFF;
				border-radius: 12rpx;

				.p1-img {

					width: 630rpx;
					height: 230rpx;
					border-radius: 12rpx 12rpx 0 0;

					image {
						position: absolute;
						left: 0;
						top: 0;
						width: 630rpx;
						height: 230rpx;
						border-radius: 12rpx 12rpx 0 0;
					}

					.p-top {
						padding-left: 36rpx;
						position: relative;
						color: #fff;

						.desc {
							margin-top: 15rpx;
							font-size: 46rpx;
						}
					}
				}

				.p1-c {
					.p-t {
						padding: 50rpx 0;
						font-size: 26rpx;
						color: #109C7A;
						text-align: center;
					}

					.p-ewm {
						margin: 0 auto;
						width: 360rpx;
						height: 360rpx;

						image {
							width: 100%;
							height: 100%;
						}
					}
				}
			}

			.pclose {
				margin: 42rpx auto 0;
				width: 70rpx;
				height: 70rpx;

				image {
					width: 100%;
					height: 100%;
				}
			}
		}
	}
</style>
